package com.rainbow.config

import com.rainbow.properties.SecurityProperties
import com.rainbow.session.MerryyouExpiredSessionStrategy
import com.rainbow.session.MerryyouInvalidSessionStrategy
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler
import org.springframework.security.web.session.InvalidSessionStrategy
import org.springframework.security.web.session.SessionInformationExpiredStrategy

/**
 *rainbow
 */
@Configuration
class SessionSecurityBeanConfig {


    @Autowired
    lateinit var securityProperties: SecurityProperties

    @Bean
    fun invalidSessionStrategy(): InvalidSessionStrategy {
        return MerryyouInvalidSessionStrategy(securityProperties.session.sessionInvalidUrl)
    }

    @Bean
    fun sessionInformationExpiredStrategy(): SessionInformationExpiredStrategy {
        return MerryyouExpiredSessionStrategy(securityProperties.session.sessionInvalidUrl)
    }

    fun logoutSuccessHandler(): LogoutSuccessHandler {
        return
    }

}